let globalData = getApp().globalData;
Page({
    data: {
        globalData,
        token: '',
        userInfo: ''
    },
    goLogin() {
        wx.navigateTo({
            url: '/pages/login/index',
        });
    },
    goMyR() {
      if (!this.data.token) {
          wx.showToast({
              title: '请登录',
              icon: 'error'
          });
          return
      }
      wx.navigateTo({
          url: '/pages/myRelease/index',
      });
  },
    goMyApply() {
        if (!this.data.token) {
            wx.showToast({
                title: '请登录',
                icon: 'error'
            });
            return
        }
        wx.navigateTo({
            url: '/pages/myApply/index',
        });
    },
    goMyData() {
        if (!this.data.token) {
            wx.showToast({
                title: '请登录',
                icon: 'error'
            });
            return
        }
        wx.navigateTo({
            url: '/pages/myData/index',
        });
    },

    goMyPost() {
        if (!this.data.token) {
            wx.showToast({
                title: '请登录',
                icon: 'error'
            });
            return
        }
        wx.navigateTo({
            url: '/pages/myPost/index',
        });
    },
    logout() {
        wx.clearStorageSync();
        this.getLocal();
    },
    getLocal() {
        const token = wx.getStorageSync('token') || '';
        const userInfo = wx.getStorageSync('userInfo') || '';
        this.setData({
            token,
            userInfo,
        })
    },
    onLoad() {
        this.getLocal()
    },
    onShow() {
        this.getLocal()
    }
})